|
|
|
|
|
|
|
(table continued from previous page) |
|
|
|
|
| C DATA TYPE | VISUAL BASIC EQUIVALENT | | long | Long | | float | Single | | double | Double | | class, struct | User-defined type | | Table T6-5: VB equivalents to the base C data types |
|
|
|
|
|
|
Handling Signed and Unsigned Types |
|
|
|
|
|
|
|
|
The C char data type is 8 bits wide, thus you would use the Visual Basic Byte data type for both signed and unsigned chars. The trick to handling these data types is to recognize the range limitations that occur during the conversion process. |
|
|
|
|
|
|
|
|
Let's say you had a C structure defined that included a signed char, and you needed to set it to 50. |
|
|
|
|
|
|
|
|
struct myStruct {
char myChar;
} |
|
|
|
|
|
|
|
|
The Visual Basic equivalent structure is: |
|
|
|
|
|
|
|
|
Type myStruct
myChar As Byte
End Type |
|
|
|
|
|
|
|
|
Dim S As myStruct
S.myChar = -50 |
|
|
|
|
|
|
|
|
you would get a range overflow error, because the Byte variable is unsigned and cannot be set to a negative number. |
|
|
|
|
|